//
//  CrowdfundingTableViewCell.m
//  Consume100
//
//  Created by eliot on 16/3/22.
//  Copyright © 2016年 aleven. All rights reserved.
//

#import "CrowdfundingTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation CrowdfundingTableViewCell

- (void) setUpCellWithArr:(NSArray *)arr {
    
    self.btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.btn1.frame = CGRectMake(self.firstIV.frame.origin.x
                                 , self.firstIV.frame.origin.y, self.firstIV.frame.size.width, self.firstIV.frame.size.height + 45);
    
    self.btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.btn2.frame = CGRectMake(self.secondIV.frame.origin.x
                                 , self.secondIV.frame.origin.y, self.secondIV.frame.size.width, self.secondIV.frame.size.height + 45);
    
    self.btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.btn3.frame = CGRectMake(self.thirdIV.frame.origin.x
                                 , self.thirdIV.frame.origin.y, self.thirdIV.frame.size.width, self.thirdIV.frame.size.height + 45);
    
    self.btn1.tag = 1;
    self.btn2.tag = 2;
    self.btn3.tag = 3;
    
    [self addSubview:self.btn1];
    [self addSubview:self.btn2];
    [self addSubview:self.btn3];
    
    [self.firstIV sd_setImageWithURL:[NSURL URLWithString:@""]];
    self.firstrPriceLb.text = @"";
    self.firstJoinNumLb.text = @"";
    self.firstProgress.hidden = YES;
    
    
    [self.secondIV sd_setImageWithURL:[NSURL URLWithString:@""]];
    self.secondPriceLb.text = @"";
    self.secondJoinNumLb.text = @"";
    self.secondProgress.hidden = YES;
    
    
    [self.thirdIV sd_setImageWithURL:[NSURL URLWithString:@""]];
    self.thridPriceLb.text = @"";
    self.thridJoinNumLb.text = @"";
    self.thridProgressView.hidden = YES;
    
    
    
    for (int i = 0; i < arr.count; i++) {
        NSDictionary *tepDic = arr[i];
        if (i == 0) {
            [self.firstIV sd_setImageWithURL:[NSURL URLWithString:tepDic[@"img"]]];
            self.firstrPriceLb.text = [NSString stringWithFormat:@"价格:￥%@", tepDic[@"price"]];
            self.firstJoinNumLb.text = [NSString stringWithFormat:@"已有%@人参加", tepDic[@"countNum"]];
            self.firstProgress.progress =  [tepDic[@"countNum"] floatValue] / [tepDic[@"inNum"] floatValue];
            self.firstProgress.hidden = NO;
        }
        if (i == 1) {
            [self.secondIV sd_setImageWithURL:[NSURL URLWithString:tepDic[@"img"]]];
            self.secondPriceLb.text = [NSString stringWithFormat:@"价格:￥%@", tepDic[@"price"]];
            self.secondJoinNumLb.text = [NSString stringWithFormat:@"已有%@人参加", tepDic[@"countNum"]];
            self.secondProgress.progress =  [tepDic[@"countNum"] floatValue] / [tepDic[@"inNum"] floatValue];
            self.secondProgress.hidden = NO;
        }
        if (i == 2) {
            [self.thirdIV sd_setImageWithURL:[NSURL URLWithString:tepDic[@"img"]]];
            self.thridPriceLb.text = [NSString stringWithFormat:@"价格:￥%@", tepDic[@"price"]];
            self.thridJoinNumLb.text = [NSString stringWithFormat:@"已有%@人参加", tepDic[@"countNum"]];
            self.thridProgressView.progress =  [tepDic[@"countNum"] floatValue] / [tepDic[@"inNum"] floatValue];
            self.thridProgressView.hidden = NO;
        }
        
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
